<%@ Page Language="C#" MasterPageFile="~/Admin/Admin.master" AutoEventWireup="true" CodeFile="Employee.aspx.cs" Inherits="Employee" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <strong><span style="font-size: 32pt">Employee Manager</span></strong><br />
    <br />
    <asp:Label ID="Label1" runat="server" ForeColor="Red"></asp:Label><br />
    <table style="width: 417px">
        <tr>
            <td rowspan="2" style="width: 2px">
                Username:</td>
            <td rowspan="2" style="width: 137px">
                <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br />
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1"
                    Display="Dynamic" ErrorMessage="Username cannot be blank"></asp:RequiredFieldValidator></td>
        </tr>
        <tr>
        </tr>
        <tr>
            <td rowspan="2" style="width: 2px">
                Password:</td>
            <td rowspan="2" style="width: 137px">
                <asp:TextBox ID="TextBox2" runat="server" TextMode="Password"></asp:TextBox><br />
                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="TextBox2"
                    Display="Dynamic" ErrorMessage="Password cannot be blank"></asp:RequiredFieldValidator></td>
        </tr>
        <tr>
        </tr>
        <tr>
            <td rowspan="2" style="width: 2px">
                Fullname:</td>
            <td rowspan="2" style="width: 137px">
                <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox><br />
                <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="TextBox3"
                    Display="Dynamic" ErrorMessage="Full name cannot be blank"></asp:RequiredFieldValidator></td>
        </tr>
        <tr>
        </tr>
        <tr>
            <td rowspan="2" style="width: 2px">
                Birthdate:</td>
            <td rowspan="2" style="width: 137px">
                <asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
                (mm/dd/yyyy)<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"
                    ControlToValidate="TextBox4" Display="Dynamic" ErrorMessage="Birthdate cannot be blank"></asp:RequiredFieldValidator><br />
                <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="TextBox4"
                    Display="Dynamic" ErrorMessage="Wrong date format" ValidationExpression="^([1-9]|0[1-9]|1[012])[- /.]([1-9]|0[1-9]|[12][0-9]|3[01])[- /.][0-9]{4}$"></asp:RegularExpressionValidator></td>
        </tr>
        <tr>
        </tr>
        <tr>
            <td rowspan="2" style="width: 2px">
                Gender:</td>
            <td rowspan="2" style="width: 137px">
                <asp:DropDownList ID="DropDownList1" runat="server">
                    <asp:ListItem Value="True">Male</asp:ListItem>
                    <asp:ListItem Value="False">Female</asp:ListItem>
                </asp:DropDownList></td>
        </tr>
        <tr>
        </tr>
        <tr>
            <td rowspan="2" style="width: 2px; height: 49px">
                Email:</td>
            <td rowspan="2" style="width: 137px; height: 49px">
                <asp:TextBox ID="TextBox6" runat="server"></asp:TextBox><br />
                <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ControlToValidate="TextBox6"
                    Display="Dynamic" ErrorMessage="Email cannot be blank"></asp:RequiredFieldValidator><br />
                <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="TextBox6"
                    Display="Dynamic" ErrorMessage="Wrong email format" ValidationExpression="^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w][^_]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$"></asp:RegularExpressionValidator></td>
        </tr>
        <tr>
        </tr>
        <tr>
            <td rowspan="2" style="width: 2px">
                Address:</td>
            <td rowspan="2" style="width: 137px">
                <asp:TextBox ID="TextBox7" runat="server"></asp:TextBox><br />
                <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ControlToValidate="TextBox7"
                    Display="Dynamic" ErrorMessage="Address cannot be blank"></asp:RequiredFieldValidator></td>
        </tr>
        <tr>
        </tr>
        <tr>
            <td rowspan="4" style="width: 2px">
                Tel:</td>
            <td rowspan="4" style="width: 137px">
                <asp:TextBox ID="TextBox8" runat="server"></asp:TextBox><br />
                <asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" ControlToValidate="TextBox8"
                    Display="Dynamic" ErrorMessage="Telephone number cannot be blank"></asp:RequiredFieldValidator></td>
        </tr>
        <tr>
        </tr>
        <tr>
        </tr>
        <tr>
        </tr>
        <tr>
            <td colspan="2">
                <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Add new employee" /></td>
        </tr>
    </table>
    <br />
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="3"
        ForeColor="Black" GridLines="Vertical" DataKeyNames="Username" DataSourceID="SqlDataSource1" OnRowDeleting="GridView1_RowDeleting" BackColor="White" BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px">
        <Columns>
            <asp:BoundField DataField="Username" HeaderText="Username" ReadOnly="True" SortExpression="Username" />
            <asp:BoundField DataField="Fullname" HeaderText="Fullname" SortExpression="Fullname" />
            <asp:BoundField DataField="Birthdate" HeaderText="Birthdate" SortExpression="Birthdate" />
            <asp:CheckBoxField DataField="Gender" HeaderText="Gender" SortExpression="Gender" />
            <asp:TemplateField>
                <ItemTemplate>
                    <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" OnClick="LinkButton1_Click">Details</asp:LinkButton>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:CommandField CausesValidation="False" ShowDeleteButton="True" />
        </Columns>
        <FooterStyle BackColor="#CCCCCC" />
        <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
        <SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
        <HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
        <AlternatingRowStyle BackColor="#CCCCCC" />
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:Con %>"
        DeleteCommand="DELETE FROM [Employee] WHERE [Username] = @Username" InsertCommand="INSERT INTO [Employee] ([Username], [Password], [Fullname], [Birthdate], [Gender], [Email], [Address], [Tel]) VALUES (@Username, @Password, @Fullname, @Birthdate, @Gender, @Email, @Address, @Tel)"
        SelectCommand="SELECT * FROM [Employee]" UpdateCommand="UPDATE [Employee] SET [Password] = @Password, [Fullname] = @Fullname, [Birthdate] = @Birthdate, [Gender] = @Gender, [Email] = @Email, [Address] = @Address, [Tel] = @Tel WHERE [Username] = @Username">
        <DeleteParameters>
            <asp:Parameter Name="Username" Type="String" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="Password" Type="String" />
            <asp:Parameter Name="Fullname" Type="String" />
            <asp:Parameter DbType="Date" Name="Birthdate" />
            <asp:Parameter Name="Gender" Type="Boolean" />
            <asp:Parameter Name="Email" Type="String" />
            <asp:Parameter Name="Address" Type="String" />
            <asp:Parameter Name="Tel" Type="String" />
            <asp:Parameter Name="Username" Type="String" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="Username" Type="String" />
            <asp:Parameter Name="Password" Type="String" />
            <asp:Parameter Name="Fullname" Type="String" />
            <asp:Parameter DbType="Date" Name="Birthdate" />
            <asp:Parameter Name="Gender" Type="Boolean" />
            <asp:Parameter Name="Email" Type="String" />
            <asp:Parameter Name="Address" Type="String" />
            <asp:Parameter Name="Tel" Type="String" />
        </InsertParameters>
    </asp:SqlDataSource>
</asp:Content>

